package sz.szsmk.citizencard.ui.newversion.activity.presenter

import sz.szsmk.citizencard.DaggerApplication
import sz.szsmk.citizencard.model.network.bean.request.IBaseRequest
import sz.szsmk.citizencard.model.network.bean.response.GestureValidBean
import sz.szsmk.citizencard.mvp.dzsmkpresenter.AppBasePresenter
import sz.szsmk.citizencard.retrofitrxjava.ErrorAction
import sz.szsmk.citizencard.retrofitrxjava.NetworkDateSources
import sz.szsmk.citizencard.retrofitrxjava.SubscribeResult
import sz.szsmk.citizencard.smkretrofit.NetworkDateSource
import sz.szsmk.citizencard.ui.newversion.activity.view.ScanQrCodeCheckMvpView
import sz.szsmk.citizencard.util.ACache
import sz.szsmk.citizencard.util.Constant
import sz.szsmk.citizencard.util.StringUtils
import javax.inject.Inject

/**
 *  @author : hyt
 *  @date : 2021/12/6
 *  @description :
 */
class ScanQrCodeChcekPresenter @Inject constructor(var httpDateSourceNotUse: NetworkDateSource) :
    AppBasePresenter<ScanQrCodeCheckMvpView>(){

    private val mNetworkDateSource = NetworkDateSources.getInstance()


    fun getGes(){
        val access_token = ACache.get(DaggerApplication.getIns()).getAsString("access_token")
        if (StringUtils.isBlank(access_token)) {
            return
        }
        val baseRequest = IBaseRequest()
        baseRequest.access_token = access_token
        mNetworkDateSource.gestureValid(baseRequest, object : SubscribeResult<GestureValidBean>() {
            override fun onOk(response: GestureValidBean) {
                mvpView.getGesSussess(response.isOpen)
            }

            override fun onFailure(response: GestureValidBean) {
                super.onFailure(response)
            }

            override fun onNext(response: GestureValidBean) {
                super.onNext(response)
            }
        }, object : ErrorAction() {
            override fun onCall(throwable: Throwable) {}
        })
    }





}